1. Field of the Invention
The present invention generally relates to computer graphics and more particularly to a method and system for processing texture samples with programmable offset positions.
2. Description of the Related Art
Unless otherwise indicated herein, the approaches described in this section are not prior art to the claims in this application and are not admitted to be prior art by inclusion in this section.
A common texture filtering approach to address aliasing artifacts involves accessing and filtering an equal number of texels along different axes that surround a pixel center mapped into texture space. Such an approach typically employs a bilinear filter or a trilinear filter. As an illustration, FIG. 1A is a texture map 100 in which a prior art 2 by 2 filter kernel accesses four adjacent texels 104, 106, 108, and 110 surrounding a pixel center 102 in a single clock cycle and then bilinear filtering the texels.
However, some texturing applications filter texels differently. One example is texture based shadow mapping, and another is highly dynamic range (HDR) rendering. Shadow mapping is a shadow rendering technique to enhance realism in computer-generated scenes. More specifically, during a shadow mapping process, a scene is first rendered from a light's point of view to generate a special texture map, commonly referred to as a shadow map, in which each texel in the shadow map stores a depth value associated with a visible surface. Then, the view of the scene is rendered from an observer's point view, by which a pixel at a (x, y) location in the screen space is projected into the light-space coordinates and then tested for visibility. This test compares the depth value of the pixel with the depth value stored at the corresponding location in the depth map to determine whether the pixel is behind an object. Based on the comparison result, the pixel is either drawn in shadow or lighted. To render smooth shadows pleasant to the eye, more than four texels from the shadow map may need to be sampled per pixel, and these texels often are not adjacent to one another.
As for the HDR rendering technique, it is a technique for preserving detail in a scene with significant contrast differences. In other words, if there are both dark and bright areas in a scene, both of the areas can be accurately represented using this technique. Similar to the shadow mapping technique described above, the HDR rendering technique also may sample more than four texels per pixel. These texels are usually distributed more sparsely than the 2 by 2 region, such as texels 124, 126, 128, and 130 shown in FIG. 1B.
Employing the prior art 2 by 2 filter kernel in the aforementioned shadow mapping and HDR rendering operations has several drawbacks. First, the 2 by 2 filter kernel is likely only able to access one of the sparsely distributed texels per clock cycle. So, to access all the desired texels, multiple clock cycles are needed. To illustrate, suppose a texturing application needs to access texels 124, 126, 128, and 130, and the prior art 2 by 2 filter kernel is used. Because the size of the 2 by 2 filter kernel is not large enough to cover all four desired texels at the same time but can cover one of the four texels, such as texel 124, three quarters of the available texture access bandwidth for the filter kernel is not used. For a texturing application needing to access more than four texels per pixel (e.g., sixteen texels), the inefficiency of the 2 by 2 filter kernel will be even more evident. Second, the prior art 2 by 2 filter kernel bilinearly weigh the sampled texels, which may not be optimal for certain texturing applications, such as the ones involving the shadow mapping and HDR rendering operations discussed above.
As the foregoing illustrates, what is needed in the art is thus a texture filtering technique that can efficiently and flexibly sample specified texels and address at least the problems set forth above.